package com.simple.elpmobile.onlinecase.ui.component;

import java.util.List;

import com.simple.elpmobile.domain.Doctor;
import com.simple.elpmobile.onlinecase.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class DocListAdapter extends BaseAdapter {

	private Context mContext;
	private List<Doctor> doctors;
	
	public DocListAdapter(Context mContext, List<Doctor> doctors) {
		super();
		this.mContext = mContext;
		this.doctors = doctors;
	}

	@Override
	public int getCount() {
		return doctors.size();
	}

	@Override
	public Object getItem(int arg0) {
		return doctors.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		return arg0;
	}

	@Override
	public View getView(int arg0, View view, ViewGroup arg2) {
		view=LayoutInflater.from(mContext).inflate(R.layout.doctor_item, null);
		TextView nameTxt=(TextView)view.findViewById(R.id.doctor_name);
		TextView sexTxt=(TextView)view.findViewById(R.id.doc_sex);
		TextView ageTxt=(TextView)view.findViewById(R.id.doc_ages);
		TextView telTxt=(TextView)view.findViewById(R.id.doc_tel);
		TextView infoTxt=(TextView)view.findViewById(R.id.doc_info);
		TextView majorTxt=(TextView)view.findViewById(R.id.doc_major);
		nameTxt.setText(doctors.get(arg0).getName());
		sexTxt.setText(doctors.get(arg0).getSex());
		ageTxt.setText(doctors.get(arg0).getAge()+"");
		telTxt.setText(doctors.get(arg0).getTel());
		infoTxt.setText(doctors.get(arg0).getInfo());
		majorTxt.setText(doctors.get(arg0).getMajor());
		return view;
	}

}
